package br.uvv.sao.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;

public class CriptoHashUtil {
	public static String hashSHA1(String senha){
		try {
			MessageDigest digest = MessageDigest.getInstance("SHA1");
			digest.update(senha.getBytes());
			BASE64Encoder encoder = new BASE64Encoder ();
			senha = encoder.encode (digest.digest ());
			return senha;
		} catch (NoSuchAlgorithmException e) {
			System.out.println("ERRO: Erro ao codificar senha.");
			e.printStackTrace();
		}
		return null;
	}
}
